class Solution2 {
    public ListNode reverseList(ListNode head) {
        if(head == null){
            return null;
        }
        ListNode cur = head.next;
        ListNode prev = null;
        ListNode next = cur.next;
        while(cur!=null){
            cur.next = prev;
            prev = cur;
            cur = next;
            next = next.next;
        }
        return prev;
    }
}